package com.tongqin.distributed;// $Id$

import java.nio.ByteBuffer;

public class CreateBuffer
{
  static public void main( String args[] ) throws Exception {
    ByteBuffer buffer = ByteBuffer.allocate( 1024 );

    buffer.put( (byte)'a' );
    System.out.println(buffer.position());
    System.out.println(buffer.capacity());
    System.out.println(buffer.limit());
    System.out.println(buffer.mark());
    buffer.put( (byte)'b' );
    System.out.println("11=="+buffer.position());
    System.out.println("11=="+buffer.capacity());
    System.out.println("11=="+buffer.limit());
    System.out.println("11=="+buffer.mark());
    buffer.put( (byte)'c' );
    System.out.println("22=="+buffer.position());
    System.out.println("22=="+buffer.capacity());
    System.out.println("22=="+buffer.limit());
    System.out.println("22=="+buffer.mark());

    buffer.flip();

    System.out.println("33=="+buffer.position());
    System.out.println("33=="+buffer.capacity());
    System.out.println("33=="+buffer.limit());
    System.out.println("33=="+buffer.mark());

    System.out.println( (char)buffer.get() );
    System.out.println("44=="+buffer.position());
    System.out.println("44=="+buffer.capacity());
    System.out.println("44=="+buffer.limit());
    System.out.println("44=="+buffer.mark());
    System.out.println( (char)buffer.get() );
    System.out.println("555=="+buffer.position());
    System.out.println("55=="+buffer.capacity());
    System.out.println("55=="+buffer.limit());
    System.out.println("55=="+buffer.mark());
    System.out.println( (char)buffer.get() );
    System.out.println("66=="+buffer.position());
    System.out.println("66=="+buffer.capacity());
    System.out.println("66=="+buffer.limit());
    System.out.println("66=="+buffer.mark());
  }
}
